<!DOCTYPE html>
<html lang="en" class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>我的需求</title>
    <header th:replace="header::html"></header>
</head>

<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a><cite>首页</cite></a>
            <a><cite>业务管理</cite></a>
            <a><cite>需求列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="layui-fluid">
    <div class="layui-row  layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form  layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="ntitle" placeholder="请输入需求标题关键字" autocomplete="off"
                                   class="layui-input">
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">请选择类型</label>
                            <div class="layui-input-inline">
                                <!--            一级-->

                                <select name="sname" id="ntype" lay-filter="typeAAA" lay-verify="typeAA" >
                                </select>

                            </div>
                        </div>


                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="search"><i
                                    class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <div class="fly-panel layui-card-body" style="margin-bottom: 0;">
                    <table class="layui-hide" id="need" lay-filter="need"></table>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
	layui.use('table', function () {
		var table = layui.table,
			form = layui.form;
		table.render({
			elem: '#need'
			, url: '/api-front/demand/userNeed' //数据接口
			, page: true //开启分页
			,skin: 'nob' //行边框风格
			,even: true //开启隔行背景
			,limit:15 //设置每页的条数

			, cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
			, response: {
				dataName: 'datas' //规定数据列表的字段名称，默认：data
			}
			, cols: [
				[ //表头

					{title: '序号', type: 'numbers', width: '5%'}
					// , {field: 'nid', title: '需求', align: 'center', sort: true, width: "5%", style: 'display:none;'}
					, {field: 'sname', title: '需求类型', align: 'center',unresize :true}
					, {field: 'ntitle', title: '需求标题', align: 'center',unresize :true}
					, {field: 'nmoney', title: '佣金', align: 'center',unresize :true}
					// , {field: 'nstarttime', title: '发布时间', align: 'center',unresize :true,width: "15%"}
					, {field: 'nendtime', title: '结束时间', align: 'center',unresize :true,width: "15%"}
					, {field: 'nrealtime', title: '工期(天)', align: 'center',unresize :true}
					, {field: 'nstate', title: '投标状态', align: 'center',unresize :true}

				]
			]



		});


		//搜索
		form.on('submit(search)', function (data) {
			var data = data.field;
			table.render({
				elem: '#need'
				, url: '/api-front/demand/findNeedByUserSearch' //数据接口
				, page: true //开启分页
				, where: {
					"ntitle": data.ntitle,
					"sname": data.sname
				}
				, response: {
					countName: 'count', //规定数据总数的字段名称，默认：count
					dataName: 'datas' //规定数据列表的字段名称，默认：data
				}
				, cols: [
					[ //表头

						{title: '序号', type: 'numbers', width: '5%'}
						// , {field: 'nid', title: '需求', align: 'center', sort: true, width: "5%", style: 'display:none;'}
						, {field: 'sname', title: '需求类型', align: 'center',unresize :true}
						, {field: 'ntitle', title: '需求标题', align: 'center',unresize :true}
						, {field: 'nmoney', title: '佣金', align: 'center',unresize :true}
						// , {field: 'nstarttime', title: '发布时间', align: 'center',unresize :true,width: "15%"}
						, {field: 'nendtime', title: '结束时间', align: 'center',unresize :true,width: "15%"}
						, {field: 'nrealtime', title: '工期(天)', align: 'center',unresize :true}
						, {field: 'nstate', title: '投标状态', align: 'center',unresize :true}

					]
				],

			});
			return false;
		});

//监听行单击事件（双击事件为：rowDouble）
		table.on('row(need)', function(obj){
			var data = obj.data;

			layer.alert(JSON.stringify(data), {
				title: '当前行数据：'
			});

			//标注选中样式
			obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
		});


		// 一级
		$(function () {
			$.ajax({
				url: "/api-front/user/sparentid",
				data: {},
				dataType: "json",
				success: function (results) {
					$("#ntype").empty();

					if (results != 0) {
						$("#ntype").append(new Option("---请选择---", ""));
						$.each(results, function (index, item) {
							$('#ntype').append(new Option(item.sname, item.sname));

						});
					} else {
						$("#ntype").append(new Option("暂无数据", ""));

					}

					layui.form.render("select");
				}
			});

		});



	});

</script>
</html>